from OpenGL.arrays import vbo
from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.GL import *
from point import Point
from numpy import array
import sys, math, os
from collections import namedtuple

def init(width, height):
   """ Initialize an OpenGL window """
   glClearColor(0.0, 0.0, 0.0, 0.0)         #background color
   glMatrixMode(GL_PROJECTION)              #switch to projection matrix
   glLoadIdentity()                         #set to 1
   gluPerspective(45., float(width)/height, 0.1, 100.0)
   glMatrixMode(GL_MODELVIEW)               #switch to modelview matrix
   
def display():
   
   

##FIXME bounding box ist seltsam meine ich
## das sind die richtigen werte der Kuh die genau im Mittelpunkt steht
##   [[-0.522196, -0.319838, -0.170141], [0.522196, 0.319838, 0.170141]]
##[0.0, 0.0, 0.0]  center 

   
def main():
   width, height = 500, 500
   glutInit(sys.argv)
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)   
   glutInitWindowSize(width, height)
   glutCreateWindow("Test OPENGL Fensterchen")
   glutDisplayFunc(display)     #register display function
   init(width, height)
   glutMainLoop()
   
   # Hack for Mac OS X
#   cwd = os.getcwd()
#   glutInit(sys.argv)
#   os.chdir(cwd)

######   glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)


   
   glutReshapeFunc(reshape)     #register reshape function
   glutKeyboardFunc(keyPressed) #register keyboard function 
   glutMouseFunc(mouse)         #register mouse function
   glutMotionFunc(mouseMotion)  #register motion function
   #glutCreateMenu(menu_func)    #register menue function




   glutAddMenuEntry("First Entry",FIRST) #Add a menu entry
   glutAddMenuEntry("EXIT",EXIT)         #Add another menu entry
   glutAttachMenu(GLUT_RIGHT_BUTTON)     #Attach mouse button to menue

   
init(500,500) #initialize OpenGL state
   # Initialize OpenGL context

   glutMainLoop() #start even processing


if __name__ == "__main__":
   main()
